```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>组合设计模式：构建树形结构的对象体系</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background-color: #f8fafc;
            color: #1e293b;
            line-height: 1.6;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
        }
        .code-block {
            background-color: #1e293b;
            color: #e2e8f0;
            border-radius: 0.5rem;
            overflow: hidden;
        }
        .code-header {
            background-color: #334155;
            padding: 0.5rem 1rem;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        .feature-card:hover {
            transform: translateY(-4px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .mermaid-container {
            background-color: white;
            border-radius: 0.5rem;
            padding: 1.5rem;
            box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
        }
        .footer-link:hover {
            color: #818cf8;
        }
        .drop-cap:first-letter {
            float: left;
            font-size: 4.5rem;
            line-height: 0.8;
            margin: 0.1em 0.2em 0 0;
            font-weight: 700;
            color: #4f46e5;
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <section class="hero-gradient text-white">
        <div class="container mx-auto px-6 py-24">
            <div class="max-w-4xl mx-auto text-center">
                <h1 class="text-4xl md:text-6xl font-bold mb-6 leading-tight">
                    组合设计模式
                </h1>
                <h2 class="text-xl md:text-2xl font-light mb-8">
                    构建树形结构的对象体系
                </h2>
                <p class="text-lg md:text-xl opacity-90 mb-10 max-w-2xl mx-auto">
                    一种将对象组合成树形结构来表示"部分-整体"层次关系的设计模式，使客户端能够统一处理单个对象和对象组合
                </p>
                <div class="flex justify-center space-x-4">
                    <a href="#overview" class="px-6 py-3 bg-white text-indigo-700 font-medium rounded-lg hover:bg-opacity-90 transition-all duration-300">
                        <i class="fas fa-book-open mr-2"></i>了解详情
                    </a>
                    <a href="#demo" class="px-6 py-3 border border-white text-white font-medium rounded-lg hover:bg-white hover:bg-opacity-10 transition-all duration-300">
                        <i class="fas fa-code mr-2"></i>查看示例
                    </a>
                </div>
            </div>
        </div>
    </section>

    <!-- Overview Section -->
    <section id="overview" class="py-20 bg-white">
        <div class="container mx-auto px-6 max-w-4xl">
            <div class="mb-16 text-center">
                <h2 class="text-3xl font-bold mb-4 text-gray-800">
                    模式概述
                </h2>
                <div class="w-20 h-1 bg-indigo-600 mx-auto"></div>
            </div>
            
            <div class="drop-cap mb-8 text-gray-700 text-lg leading-relaxed">
                组合设计模式是一种结构型设计模式，它允许你将对象组合成树形结构来表示"部分-整体"的层次关系。该模式允许客户端以一致的方式处理单个对象和对象组合，从而使得对象的嵌套结构更加灵活和统一。
            </div>
            
            <div class="grid md:grid-cols-2 gap-8 mt-12">
                <div class="feature-card bg-gray-50 p-8 rounded-xl border border-gray-200 transition-all duration-300">
                    <div class="text-indigo-600 text-4xl mb-4">
                        <i class="fas fa-sitemap"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3 text-gray-800">树形结构</h3>
                    <p class="text-gray-600">组合模式将对象组织成树形结构，可以是单个对象，也可以是对象的组合。</p>
                </div>
                
                <div class="feature-card bg-gray-50 p-8 rounded-xl border border-gray-200 transition-all duration-300">
                    <div class="text-indigo-600 text-4xl mb-4">
                        <i class="fas fa-project-diagram"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3 text-gray-800">透明性</h3>
                    <p class="text-gray-600">组合模式使客户端无需区分单个对象和对象组合，对它们的操作方法一致。</p>
                </div>
                
                <div class="feature-card bg-gray-50 p-8 rounded-xl border border-gray-200 transition-all duration-300">
                    <div class="text-indigo-600 text-4xl mb-4">
                        <i class="fas fa-code"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3 text-gray-800">简化客户端代码</h3>
                    <p class="text-gray-600">客户端通过统一的接口操作对象，无需考虑对象的嵌套关系，简化了代码逻辑。</p>
                </div>
                
                <div class="feature-card bg-gray-50 p-8 rounded-xl border border-gray-200 transition-all duration-300">
                    <div class="text-indigo-600 text-4xl mb-4">
                        <i class="fas fa-cogs"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3 text-gray-800">灵活性</h3>
                    <p class="text-gray-600">可以动态地添加、删除对象，从而构建不同的树形结构。</p>
                </div>
            </div>
        </div>
    </section>

    <!-- Use Cases Section -->
    <section class="py-20 bg-gray-50">
        <div class="container mx-auto px-6 max-w-4xl">
            <div class="mb-16 text-center">
                <h2 class="text-3xl font-bold mb-4 text-gray-800">
                    使用场景
                </h2>
                <div class="w-20 h-1 bg-indigo-600 mx-auto"></div>
            </div>
            
            <div class="mermaid-container mb-12">
                <div class="mermaid">
                    graph TD
                    A[组合模式适用场景] --> B[树状结构]
                    A --> C[递归处理]
                    A --> D[GUI界面]
                    B --> B1[文件系统]
                    B --> B2[组织架构]
                    C --> C1[目录遍历]
                    C --> C2[数据聚合]
                    D --> D1[UI组件嵌套]
                    D --> D2[游戏场景图]
                </div>
            </div>
            
            <div class="space-y-8">
                <div class="bg-white p-6 rounded-lg shadow-sm border border-gray-100">
                    <h3 class="text-xl font-semibold mb-3 text-gray-800 flex items-center">
                        <span class="w-8 h-8 rounded-full bg-indigo-100 text-indigo-700 flex items-center justify-center mr-3">
                            1
                        </span>
                        树状结构
                    </h3>
                    <p class="text-gray-700 pl-11">
                        当存在树状结构，且需要统一处理每个节点时，可以考虑使用组合模式。例如文件系统中的文件和文件夹，组织架构中的部门和员工等。
                    </p>
                </div>
                
                <div class="bg-white p-6 rounded-lg shadow-sm border border-gray-100">
                    <h3 class="text-xl font-semibold mb-3 text-gray-800 flex items-center">
                        <span class="w-8 h-8 rounded-full bg-indigo-100 text-indigo-700 flex items-center justify-center mr-3">
                            2
                        </span>
                        递归处理
                    </h3>
                    <p class="text-gray-700 pl-11">
                        对象的嵌套结构需要递归地处理时，组合模式可以帮助简化代码。例如计算目录大小需要遍历所有子目录和文件。
                    </p>
                </div>
                
                <div class="bg-white p-6 rounded-lg shadow-sm border border-gray-100">
                    <h3 class="text-xl font-semibold mb-3 text-gray-800 flex items-center">
                        <span class="w-8 h-8 rounded-full bg-indigo-100 text-indigo-700 flex items-center justify-center mr-3">
                            3
                        </span>
                        GUI界面
                    </h3>
                    <p class="text-gray-700 pl-11">
                        在构建复杂的GUI界面中，可以使用组合模式来表示UI控件的嵌套关系。例如窗口包含面板，面板包含按钮、文本框等控件。
                    </p>
                </div>
            </div>
        </div>
    </section>

    <!-- Framework Applications Section -->
    <section class="py-20 bg-white">
        <div class="container mx-auto px-6 max-w-4xl">
            <div class="mb-16 text-center">
                <h2 class="text-3xl font-bold mb-4 text-gray-800">
                    框架中的应用
                </h2>
                <div class="w-20 h-1 bg-indigo-600 mx-auto"></div>
            </div>
            
            <div class="flex flex-col md:flex-row gap-8">
                <div class="flex-1 bg-indigo-50 p-8 rounded-xl">
                    <div class="flex items-center mb-4">
                        <div class="w-12 h-12 rounded-lg bg-indigo-100 text-indigo-700 flex items-center justify-center text-2xl mr-4">
                            <i class="fab fa-java"></i>
                        </div>
                        <h3 class="text-xl font-semibold text-gray-800">Java AWT和Swing</h3>
                    </div>
                    <p class="text-gray-700">
                        Java的GUI库中，容器和组件的层次结构就使用了组合模式，通过不同的容器(如JPanel)和组件(如JButton)来构建复杂的界面。
                        Container和Component类构成了树形结构，Container可以包含其他Component，包括其他Container。
                    </p>
                </div>
                
                <div class="flex-1 bg-indigo-50 p-8 rounded-xl">
                    <div class="flex items-center mb-4">
                        <div class="w-12 h-12 rounded-lg bg-indigo-100 text-indigo-700 flex items-center justify-center text-2xl mr-4">
                            <i class="fas fa-database"></i>
                        </div>
                        <h3 class="text-xl font-semibold text-gray-800">Hibernate框架</h3>
                    </div>
                    <p class="text-gray-700">
                        Hibernate中的持久化对象和关联关系，也可以使用组合模式来表示对象之间的层次关系。
                        例如，一个订单对象可能包含多个订单项对象，这种"整体-部分"关系可以通过组合模式来实现。
                    </p>
                </div>
            </div>
        </div>
    </section>

    <!-- Demo Section -->
    <section id="demo" class="py-20 bg-gray-50">
        <div class="container mx-auto px-6 max-w-4xl">
            <div class="mb-16 text-center">
                <h2 class="text-3xl font-bold mb-4 text-gray-800">
                    实现示例
                </h2>
                <div class="w-20 h-1 bg-indigo-600 mx-auto"></div>
            </div>
            
            <p class="text-gray-700 mb-8 text-lg">
                以下是一个简单的组合模式示例，实现了一个文件系统的层次结构，可以表示文件和文件夹的嵌套关系：
            </p>
            
            <div class="code-block rounded-lg mb-8">
                <div class="code-header">
                    <div class="text-gray-300 text-sm">
                        <i class="fas fa-file-code mr-2"></i>FileSystemExample.java
                    </div>
                    <div class="flex">
                        <span class="w-3 h-3 rounded-full bg-red-500 mr-2"></span>
                        <span class="w-3 h-3 rounded-full bg-yellow-500 mr-2"></span>
                        <span class="w-3 h-3 rounded-full bg-green-500"></span>
                    </div>
                </div>
                <pre class="p-4 overflow-x-auto"><code class="language-java">// 组件接口
interface FileSystemComponent {
    void display();
}

// 文件类
class File implements FileSystemComponent {
    private String name;

    public File(String name) {
        this.name = name;
    }

    public void display() {
        System.out.println("File: " + name);
    }
}

// 文件夹类
class Folder implements FileSystemComponent {
    private String name;
    private List&lt;FileSystemComponent&gt; children = new ArrayList&lt;&gt;();

    public Folder(String name) {
        this.name = name;
    }

    public void add(FileSystemComponent component) {
        children.add(component);
    }

    public void display() {
        System.out.println("Folder: " + name);
        for (FileSystemComponent component : children) {
            component.display();
        }
    }
}

public class CompositePatternDemo {
    public static void main(String[] args) {
        File file1 = new File("file1.txt");
        File file2 = new File("file2.txt");
        Folder folder1 = new Folder("folder1");
        Folder folder2 = new Folder("folder2");

        folder1.add(file1);
        folder2.add(file2);
        folder2.add(folder1);

        folder2.display();
    }
}</code></pre>
            </div>
            
            <div class="mermaid-container">
                <div class="mermaid">
                    graph TD
                    A[FileSystemComponent] <|-- B[File]
                    A <|-- C[Folder]
                    C --> D[children: List&lt;FileSystemComponent&gt;]
                    B --> E[+display(): void]
                    C --> F[+add(component: FileSystemComponent): void]
                    C --> G[+display(): void]
                </div>
            </div>
            
            <div class="mt-8 bg-white p-6 rounded-lg border-l-4 border-indigo-500">
                <h3 class="text-xl font-semibold mb-3 text-gray-800 flex items-center">
                    <i class="fas fa-lightbulb text-yellow-500 mr-3"></i>
                    模式总结
                </h3>
                <p class="text-gray-700">
                    组合设计模式允许将对象组织成树形结构，从而方便地处理对象的嵌套关系。通过使用统一的接口，客户端代码可以一致地处理单个对象和对象组合，使得系统更具灵活性和可扩展性。
                </p>
            </div>
        </div>
    </section>

    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-400 py-8">
        <div class="container mx-auto px-6 text-center">
            <div class="mb-4">
                <h3 class="text-xl font-medium text-white mb-2">技术小馆</h3>
                <a href="http://www.yuque.com/jtostring" class="footer-link hover:text-indigo-400 transition-colors duration-300">
                    <i class="fas fa-external-link-alt mr-2"></i>http://www.yuque.com/jtostring
                </a>
            </div>
            <p class="text-sm opacity-75">
                &copy; 2023 技术小馆. 保留所有权利.
            </p>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });
    </script>
</body>
</html>
```